import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;

public class BufferedFileCharWriter {
    public static void main(String[] args) {
        try {
            FileWriter fileWriter = new FileWriter("write_char_file.txt");
            // fileWriter.write("测试")

            BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
            // 将内容写入到缓冲区
            bufferedWriter.write("输出缓冲区测试");
            bufferedWriter.newLine();

            // 将缓冲区中的内容写入到文件，即清空缓冲区。
            bufferedWriter.flush();

            bufferedWriter.close();
            fileWriter.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
